package edu.gatech.stolen.tea;

public enum Month {
	
	JANUARY (1, 31),
	FEBRUARY (2, 29),
	MARCH (3, 31),
	APRIL (4, 30),
	MAY (5, 31),
	JUNE (6, 30),
	JULY (7, 31),
	AUGUST (8, 31),
	SEPTEMBER (9, 30),
	OCTOBER (10, 31),
	NOVEMBER (11, 30),
	DECEMBER (12, 31);
	
	private final int month;
	private final int days;
	private int day;
	private int year;
	
	Month (int month, int days) {
		
		this.month = month;
		this.days = days;
		
	}
	
	public int getMonth() { return month; }
	public int getDays() { return days; }
	
	public void setDay(Day d) {
		
		if(d.getDay() > days) {
			day = days;
		}
		else {
			this.day = d.getDay();
		}
		
	}
	
	public int getDay() {
		
		return day;
		
	}
	
	public void setYear(int y) {
		
		this.year = y;
		
	}
	
	public int getYear() {
		
		return year;
		
	}
	
	public String getDate() {
		
		return String.valueOf(month) + "/" + String.valueOf(day) + "/" + String.valueOf(year);
		
	}
	
	/**
	 * compares Months, a result of >0 means this Months comes first, less than 0 means the other Month,
	 * 0, means they're the same
	 * 
	 * @param m
	 * @return a negative integer, zero, or a positive integer
	 */
	public int compare(Month m) {
		
		int otherMonth = m.getMonth();
		int otherDay = m.getDay();
		int otherYear = m.getYear();
		
		if (year != otherYear){
			return otherYear - year;
		}
		else if (month != m.getMonth()) {
			return otherMonth - month;
		}
		else if (day != otherDay) {
			return otherDay - day;
		}
		
		return 0;
		
	}

}
